// 利用多态实现计算器功能
#include <iostream>
#include <string>
using namespace std;
class AbstractCalculator {
public:
    int m_num1;
    int m_num2;
    virtual int getResult() {
        return 0;
    }
};
class AddCalculator: public AbstractCalculator {
public:
    AddCalculator(int n1, int n2);
    int getResult() {
        return m_num1 + m_num2;
    }
};
AddCalculator::AddCalculator(int n1, int n2) {
    this->m_num1 = n1;
    this->m_num2 = n2;
}
class SubCalculator: public AbstractCalculator {
public:
    SubCalculator(int n1, int n2);
    int getResult() {
        return m_num1 - m_num2;
    }
};
SubCalculator::SubCalculator(int n1, int n2) {
    this->m_num1 = n1;
    this->m_num2 = n2;
}
class MulCalculator: public AbstractCalculator {
public:
    MulCalculator(int n1, int n2);
    int getResult() {
        return m_num1 * m_num2;
    }
};
MulCalculator::MulCalculator(int n1, int n2) {
    this->m_num1 = n1;
    this->m_num2 = n2;
}
void test1() {
    AbstractCalculator *ac1 = new AddCalculator(104, 200);
    cout << "add " << ac1->getResult() << endl;
    delete ac1;

    ac1 = new SubCalculator(505, 200);
    cout << "sub " << ac1->getResult() << endl;
    delete ac1;

    ac1 = new MulCalculator(10, 24);
    cout << "mul " << ac1->getResult() << endl;
    delete ac1;

}
int main(void) {
    test1();

    return 0;
}